﻿<UserControl x:Class="ManageInfo.View.ManageInfoView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:converter="clr-namespace:Infrastructure.Converters;assembly=Infrastructure">
    <UserControl.Resources>
        <converter:ValidConverter x:Key="ValidConverter"/>
        <converter:WCNOLinesConverter x:Key="sourceConverter"/>
        <converter:WCNOConverter x:Key="itemConverter"/>
        <converter:ValidToVisibleConverter x:Key="ValidToVisibleConverter"/>
        <DataTemplate x:Key="ComboBoxSimpleTemplate">
            <Grid>
                <TextBlock Text="{Binding UserName}" />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="ImageListBoxTemplate">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsChecked,Mode=TwoWay}"></CheckBox>
                <TextBlock Text="{Binding ImagePath}" Margin="5 0 0 0"></TextBlock>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <telerik:RadBusyIndicator IsBusy="{Binding IsBusy}" BusyContent="{Binding MessageContent}" DisplayAfter="0" IsIndeterminate="True" >
        <Grid Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" Margin="0 8 0 0" HorizontalAlignment="Left">
                <TextBlock Text="流水线名:" Width="80"></TextBlock>
                <telerik:RadComboBox ItemsSource="{Binding WCNOLines,Converter={StaticResource sourceConverter}}" 
                                     SelectedItem="{Binding WCNO,Converter={StaticResource itemConverter}}" 
                                     IsEditable="False" Width="180"></telerik:RadComboBox>
            </StackPanel>
            <StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 8 0 0">
                <TextBlock Text="工位名称:" Width="80"></TextBlock>
                <telerik:RadComboBox ItemsSource="{Binding StationNames}" SelectedItem="{Binding SelectedStationName}" 
                                     IsEditable="False" Width="180"></telerik:RadComboBox>
            </StackPanel>
            <StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 8 0 0">
                <TextBlock Text="机种名:" Width="80"></TextBlock>
                <TextBox Text="{Binding Model,UpdateSourceTrigger=PropertyChanged}" Width="180"></TextBox>
            </StackPanel>
            <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" Margin="0 8 0 0">
                <TextBlock Text="背番号:" Width="80"></TextBlock>
                <TextBox Text="{Binding Sebango,UpdateSourceTrigger=PropertyChanged}" Width="180"></TextBox>
            </StackPanel>
            <StackPanel Grid.Row="2" Grid.Column="0" Orientation="Vertical" Margin="0 8 0 0" Grid.RowSpan="6">
                <TextBlock Text="选择图片:" Width="80" HorizontalAlignment="Left"></TextBlock>
                <telerik:RadListBox SelectedItem="{Binding SelectedImageModel, Mode=TwoWay}" Height="180" HorizontalAlignment="Left"
							ItemsSource="{Binding ImageList}" ItemTemplate="{StaticResource ImageListBoxTemplate}" Width="260" Margin="0 5 0 0"/>
            </StackPanel>
            <StackPanel Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 8 0 0">
                <TextBlock Text="用户名:" Width="80"></TextBlock>
                <telerik:RadComboBox x:Name="UserName" ItemsSource="{Binding UserNames}" SelectedItem="{Binding SelectedUserName}"
                                 telerik:TextSearch.TextPath="UserName" Width="180" Height="22" VerticalAlignment="Top"
                                 ItemTemplate="{StaticResource ComboBoxSimpleTemplate}" ></telerik:RadComboBox>
            </StackPanel>
            <StackPanel Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 8 0 0">
                <TextBlock Text="使用状态:" Width="80"></TextBlock>
                <RadioButton Content="预备" GroupName="validGroup" Width="60" IsChecked="{Binding IsValidZeroChecked,Mode=TwoWay}"></RadioButton>
                <RadioButton Content="现行" GroupName="validGroup" Width="60" IsChecked="{Binding IsValidOneChecked,Mode=TwoWay}"></RadioButton>
                <RadioButton Content="旧" GroupName="validGroup" Width="60" IsChecked="{Binding IsValidTwoChecked,Mode=TwoWay}"></RadioButton>
            </StackPanel>
            <StackPanel Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 8 0 0">
                <TextBlock Text="创建时间:" Width="80"></TextBlock>
            </StackPanel>
            <StackPanel Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 8 0 0">
                <telerik:RadDateTimePicker Width="260" DateTimeWatermarkContent="开始时间" Height="22" Culture="zh-CN"
				VerticalAlignment="Top" DisplayFormat="Short" InputMode="DateTimePicker" IsReadOnly="False" DateSelectionMode="Day">
                    <telerik:RadDateTimePicker.SelectedValue>
                        <Binding Path="FromDate" 
                             NotifyOnValidationError="True" 
                             Mode="TwoWay" 
                             UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule/>
                            </Binding.ValidationRules>
                        </Binding>
                    </telerik:RadDateTimePicker.SelectedValue>
                </telerik:RadDateTimePicker>
            </StackPanel>
            <StackPanel Grid.Row="6" Grid.Column="1" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 8 0 0">
                <telerik:RadDateTimePicker Width="260" DateTimeWatermarkContent="结束时间" Height="22" DateSelectionMode="Day" 
				VerticalAlignment="Top" DisplayFormat="Short" InputMode="DateTimePicker" IsReadOnly="False" Culture="zh-CN">
                    <telerik:RadDateTimePicker.SelectedValue>
                        <Binding Path="ToDate" 
                             NotifyOnValidationError="True" 
                             Mode="TwoWay" 
                             UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule/>
                            </Binding.ValidationRules>
                        </Binding>
                    </telerik:RadDateTimePicker.SelectedValue>
                </telerik:RadDateTimePicker>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0 8 0 0">
                <telerik:RadButton Width="60" Height="22" Content="确定" Margin="0 0 5 0" Command="{Binding SaveCommand,Mode=TwoWay}"></telerik:RadButton>
                <telerik:RadButton Width="60" Height="22" Content="应用" Margin="0 0 5 0" Command="{Binding ApplyCommand,Mode=TwoWay}"></telerik:RadButton>
                <telerik:RadButton Width="60" Height="22" Content="预览" Margin="0 0 5 0" Command="{Binding PreviewCommand,Mode=TwoWay}"></telerik:RadButton>
                <telerik:RadButton Width="60" Height="22" Content="编辑" Margin="0 0 5 0" Command="{Binding EditCommand,Mode=TwoWay}"></telerik:RadButton>
                <telerik:RadButton Width="60" Height="22" Content="删除" Margin="0 0 5 0" Command="{Binding DeleteCommand,Mode=TwoWay}"></telerik:RadButton>
                <telerik:RadButton Width="60" Height="22" Content="导出" Margin="0 0 5 0" Command="{Binding ExportCommand,Mode=TwoWay}"></telerik:RadButton>
            </StackPanel>
            <telerik:RadGridView Grid.ColumnSpan="2" Grid.Row="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0 10 0 0"
                                ItemsSource="{Binding MachineInfo}" CanUserInsertRows="False" AutoGenerateColumns="False"
                                ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                ShowGroupPanel="False" SelectedItem="{Binding SelectedMachineInfo}">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewColumn Header="流水线名" MinWidth="80">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding WCNO}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="工位名称" MinWidth="80">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding StationName}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="机种名" MinWidth="80">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Model}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="背番号" MinWidth="80">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Sebango}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="使用状态" MinWidth="80">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Valid,Converter={StaticResource ValidConverter}}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="提示文件名称" Width="*">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Essentials}" ToolTip="{Binding Essentials}"/>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="循环播放时间" MinWidth="80">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding CycleTime}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="设定用户" MinWidth="80">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding SetId}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="设定时间" MinWidth="120">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding SetDate}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="应用用户" MinWidth="80">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding ApplyId}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                    <telerik:GridViewColumn Header="应用时间" MinWidth="120">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding ApplyDate}"  />
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
